package com.shushan.mixedexam.strangewords.bean;

import com.android.net.bean.NetBaseBean;
import com.shushan.base.Constants;
import com.shushan.mixedexam.bean.NewTypePaperInfoBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: StrangeWordsTopicsBean
 * @Desciption: //生字练习题bean
 * @author: zhangshihao
 * @date: 2018-07-24
 */
public class StrangeWordsTopicsBean extends NetBaseBean {

    private List<StrangeWordsExerciseBean> strangeWordsExerciseBeans = new ArrayList<>();

    public NewTypePaperInfoBean paperInfoBean;

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }
        JSONArray exerciseArr = jsonObject.optJSONArray("sz");
        if(exerciseArr != null && exerciseArr.length() > 0){
            for(int i=0;i<exerciseArr.length();i++){
                JSONObject jobj = exerciseArr.optJSONObject(i);
                StrangeWordsExerciseBean exerciseBean = new StrangeWordsExerciseBean();
                exerciseBean.initByJson(jobj);
                strangeWordsExerciseBeans.add(exerciseBean);
            }
        }

        JSONObject paperInfoObj = jsonObject.optJSONObject("paper_info");
        if(paperInfoObj != null){
            paperInfoBean = new NewTypePaperInfoBean();
            paperInfoBean.initByJson(paperInfoObj);
        }

    }

    public List<StrangeWordsExerciseBean> getStrangeWordsExerciseBeans() {
        return strangeWordsExerciseBeans;
    }

}
